package com.atguigu.yygh.msm.utils;

import lombok.Data;
import lombok.ToString;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
 * @author mengWu
 * @Date 2021年05月25日 12:09
 */

@Configuration
@ConfigurationProperties(prefix = "tencent.msm",ignoreInvalidFields =false)
@PropertySource("classpath:/tencent.properties")
@Component
@Data
@ToString
public class TencentProperties implements InitializingBean {
    /**
     * Spring中的 InitializingBean 接口的使用：
     *  1、InitializingBean接口中包含名为 afterPropertiesSet 的抽象方法，凡是继承该接口的类，必须重写该方法！
     *  2、实现了 InitializingBean 接口的类会在Spring初始化Bean的时候会自动调用 afterPropertiesSet 方法！
     */

    private String secretId;
    private String secretKey;
    private String region;
    private String appid;
    private String sign; // 签名内容
    private String templateID;


    public static String SECRET_ID;
    public static String SECRET_KEY;
    public static String REGION;
    public static String APP_ID;
    public static String SIGN; // 签名内容
    public static String TEMPLATE_ID;


    @Override
    public void afterPropertiesSet() throws Exception {
        SECRET_ID = this.secretId;
        SECRET_KEY = this.secretKey;
        REGION = this.region;
        APP_ID = this.appid;
        SIGN = this.sign;
        TEMPLATE_ID = this.templateID;
    }
}
